<?php
session_start();
global $data, $jazyk, $hero;
$base = "http://localhost/PreparingForBattle/";
$jazyk = "en";

//---------------------------------------
// NAČTENÍ KNIHOVEN
include "function/db_connect.php";
include "function/fce_core.php";
include "function/fce_news.php";
include "function/fce_lang.php";
include "function/fce_forms.php";
include "function/fce_html.php";
include "function/fce_crypt.php";

//---------------------------------------
// NAHRÁVÁNÍ DAT
loadData();
character_ini();

//---------------------------------------
// XFUNCTION
if ((isset($_POST["xfunction"]) && $_POST["xfunction"] != "") OR (isset($_GET["xfunction"]) && $_GET["xfunction"] != "") OR (isset($_GET["sekce"]) && substr($_GET["sekce"], 0, 1) == "x"))
{    
    include "xfunction.php";
    if (isset($_POST["xfunction"]) && $_POST["xfunction"] != "") 
    {
        $_POST["xfunction"]();           
    }
    
    if (isset($_GET["xfunction"]) && $_GET["xfunction"] != "") 
    {
        $_GET["xfunction"]();           
    }
    
    if (isset($_GET["sekce"]) && substr($_GET["sekce"], 0, 1) == "x")
    {
        $_GET["sekce"]();
    }
}

//---------------------------------------
// NAČÍTÁNÍ STYLŮ A JAVASCRIPTŮ
// styly
$styles = array();
$styles[] = "style/main.css";
$styles[] = "style/loginPage.css";

// javascripty
$scripts = array();
?>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Legendy Vanhamaa | Ozvěny války</title>
        <?php
        foreach ($styles as $style)
        {
            echo '<link rel="stylesheet" href="' . $base . $style . '">';
        }
        
        foreach ($scripts as $script)
        {
            echo '<script src="' . $base . $script . '"></script>';
        }
        ?>
        <link href='http://fonts.googleapis.com/css?family=Eagle+Lake&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
    </head>
    <body>
        <?php
        if (!isset($data["user"]["id"]))
        {
            include "login.php";
        }
        else
        {
            include "mainPage.php";
        }
        ?>
    </body>
</html>

<?php
    saveData();
?>